<template>
  <div class="list_goods_hot">
    <div class="card_goods_list list list-x">
      <div
        v-for="(o, i) in list"
        :key="i"
        class="goods_hot_item item col-6 col-sm-4 col-md-12"
      >
        <router-link
          :to="{ path: '/goods/details', query: { goods_id: o[vm.goods_id] } }"
          class="goods_nav"
        >
          <div class="icon">
            <img
              style="width: 100%; height: 100%"
              :src="$fullUrl(o[vm.img])"
              alt="图片丢失"
            />
          </div>

          <div class="good_bottom">
            <div class="ellipsis_2 title">{{ o[vm.title] }}</div>
            <div class="price_block">
              <span class="price">￥{{ o[vm.price] }}</span>
              <span class="price_ago">￥{{ o[vm.price_ago] }}</span>
            </div>
          </div>
        </router-link>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    url: {
      type: String,
      default: "/pages/goods/details?goods_id=",
    },
    list: {
      type: Array,
      default: function () {
        return [];
      },
    },
    vm: {
      type: Object,
      default: function () {
        return {
          goods_id: "goods_id",
          img: "img",
          title: "title",
          price: "price",
          price_ago: "price_ago",
        };
      },
    },
    span: {
      type: Number,
      default: 2,
    },
  },
  data() {
    var col = 12 / this.span;
    return {
      col,
    };
  },
  methods: {},
  components: {},
};
</script>

<style scoped>
.ellipsis_2 {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.list_goods {
  background-color: #f8f8f8;
}
.goods_hot_block {
  display: block;
  margin-top: 18px;
}
.goods_hot_item {
  border: 1px solid #eee;
}
.goods_hot_item .goods_nav {
  padding: 0.2rem 0.5rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.goods {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 95%;
  margin-top: 0.5rem;
}

.figure {
  width: 160px;
  height: 160px;
  padding: 2px;
  margin: 2px auto;
  box-shadow: none;
}
.good_bottom {
  font-size: 0.8rem;
  margin: 4px 10px;
}
.good_bottom .title {
  text-align: center;
}
.good_bottom .price_block {
  text-align: center;
}
.title_wrap {
  margin-bottom: 0.3rem;
}

.price {
  color: var(--color_primary_b);
  font-weight: 600;
}

.price_ago {
  text-decoration: line-through;
  font-size: 0.4rem;
  color: #999;
}
.icon_cart {
  position: absolute;
  right: 0;
}
</style>
